from django.db import models


# Create your models here.
class BookInfo(models.Model):
    name = models.CharField(max_length=10, verbose_name='书籍名称')

    # 内置函数 admin中显示当前模型的书籍名称
    def __str__(self):
        return self.name

    # 内部类：修改当前模型的中文名称
    class Meta:
        verbose_name = '书籍管理'
        # 在admin中删除s后缀
        verbose_name_plural = verbose_name


class PeopleInfo(models.Model):
    name = models.CharField(max_length=10, verbose_name='人物名称')
    gender = models.BooleanField(verbose_name='性别')
    # 外键
    book = models.ForeignKey(BookInfo, on_delete=models.CASCADE, verbose_name='所属书籍')

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = '人物管理'
        verbose_name_plural = verbose_name




